package com.objectdraw.client.objectdraw;
//import java.awt.*;
import java.awt.event.*;
import java.util.EventListener;
import javax.swing.*;



/**
 * Containter used to hold color selection box, control buttons, and update canvas button.
 *
 * @author jgulik, cfruehan
 *
 */
@SuppressWarnings("serial")
public class ControlPanel extends JPanel {

	protected JButton clearButton;
	protected JComboBox comboBox;
	protected JButton controlButton;
	protected JButton releaseButton;
	protected JButton updateButton;


	/* Constructor  */

	/**
	 * initialized the control panel.  adds color selection combo box and other buttons.
	 */
	public ControlPanel() { 
		clearButton = new JButton("Clear");
		add(clearButton);
		add(new JLabel("Pen color"));
		comboBox = new JComboBox();
		comboBox.addItem("black");
		comboBox.addItem("blue");
		comboBox.addItem("green");
		comboBox.addItem("red");
		add(comboBox);
		controlButton=new JButton("Request Control");
		add(controlButton);
		releaseButton = new JButton("Release Control");
		add(releaseButton);
		updateButton = new JButton("Update Canvas");
		add(updateButton);
	}

	protected void addControlPanelListener(EventListener listener)  {
		clearButton.addActionListener((ActionListener)listener);
		comboBox.addItemListener((ItemListener)listener);
		controlButton.addActionListener((ActionListener)listener);
		releaseButton.addActionListener((ActionListener)listener);
		updateButton.addActionListener((ActionListener)listener);
	}
}
